package com.fs.system.student.service;

import com.fs.system.exception.CustomerException;
import com.fs.system.student.domain.ActType;
import com.fs.system.student.domain.ApplicationRecord;
import com.fs.system.student.mapper.ApplicationRecordMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class ApplicationRecordService {

    @Resource
    private ApplicationRecordMapper applicationRecordMapper;

    public void submitApply(ApplicationRecord applicationRecord) {
        // 设置申请状态为待分配：“1”
        applicationRecord.setStatus("1");
        applicationRecord.setCreateTime(LocalDateTime.now());
        applicationRecordMapper.addRecord(applicationRecord);
    }

    public List<ApplicationRecord> selectApplyRecordList(ApplicationRecord applyRecord) {
        return applicationRecordMapper.selectApplyRecordList(applyRecord);
    }

    public PageInfo<ApplicationRecord> selectPage(ApplicationRecord applyRecord, Integer pageNum, Integer pageSize) {
        //开启分页查询（传参：当前页码、每页分页个数）
        PageHelper.startPage(pageNum,pageSize);
        //查询所有的数据
        List<ApplicationRecord> applyRecordList = applicationRecordMapper.selectApplyRecordList(applyRecord);
        //PageInfo执行分页操作
        return PageInfo.of(applyRecordList);
    }
}
